package org.linuxsogood.boot.quartz;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * @author honway.liu
 * @date 2018/9/19 下午9:57
 * @email gm100861@gmail.com
 * @blog http://linuxsogood.org
 */
public class Demo1 {

    public static void main(String[] args) throws SchedulerException {
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();


        JobDetail jobDetail = JobBuilder.newJob(MyJob.class)
                                        .withIdentity(JobKey.jobKey("myJob", "my group"))
                                        .build();

        CronTrigger trigger = TriggerBuilder.newTrigger()
                .startNow()
                .withSchedule(CronScheduleBuilder.cronSchedule("0/5 * * * * ?"))
                .withIdentity("trigger1")
                .build();

        scheduler.scheduleJob(jobDetail, trigger);

        scheduler.start();

    }
}
